package com.imooc.mall.util;

import com.imooc.mall.common.Constant;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;

/**
 * MD5加密工具
 */
public class MD5Utils {
    public static String getMD5(String str) throws NoSuchAlgorithmException {
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        return Base64.getEncoder().encodeToString(md5.digest((str + Constant.SALT).getBytes()));
    }
}
